package office.action.hr;

import java.util.List;

import office.action.hr.form.OfficesuppliesForm;
import office.service.hr.IOfficesuppliesService;
import platform.common.action.BaseAction;
import platform.util.Util;

@SuppressWarnings("serial")
public class OfficesuppliesAction extends BaseAction{
	private IOfficesuppliesService officesuppliesService;
	@SuppressWarnings("unchecked")
	private List wrapperList;
	private String id;
	private OfficesuppliesForm objctForm;
	@SuppressWarnings("unchecked")
	private List sortList;
	/**
	 * 获取申请办公用品信息
	 * @return
	 * @throws Exception
	 */
	public String officesuppliesList()throws Exception{
		wrapperList = officesuppliesService.getOfficesuppliesList();
		return "showList";
	}
	
	/**
	 * 跳转到编辑页面
	 * @return
	 * @throws Exception
	 */
	public String gotoAdd()throws Exception{
		sortList = Util.parsePropertiesReturnList("office","OfficesuppliesSort.size");
		return "gotoEdit";
	}
	
	/**
	 * 跳转到编辑页面
	 * @return
	 * @throws Exception
	 */
	public String gotoEdit()throws Exception{
		sortList = Util.parsePropertiesReturnList("office","OfficesuppliesSort.size");
		objctForm = officesuppliesService.getById(id);
		return "gotoEdit";
	}
	/**
	 * 添加或编辑数据
	 * @return
	 * @throws Exception
	 */
	public String editData() throws Exception{
		try {
			officesuppliesService.editOfficesupplies(objctForm);
			if(null==objctForm.getId() || ("").equals(objctForm.getId())){
				this.getAjaxMessagesJson().setMessage(true, "", "新建成功");
			}else{
				this.getAjaxMessagesJson().setMessage(true, "", "编辑成功");
			}
			
		} catch (Exception e) {
			this.handleException(e);
		}
		return RESULT_AJAXJSON;
	}
	/**
	 * 初始化可用操作
	 * @return
	 * @throws Exception
	 */
	public String gotoEditXml()throws Exception{
		objctForm = officesuppliesService.getById(id);
		return "editXml";
	}
	/**
	 * 初始化删除
	 * @return
	 * @throws Exception
	 */
	public String gotoDel()throws Exception{
		return "gotoDel";
	}
	/**
	 * 删除
	 * @return
	 * @throws Exception
	 */
	public String delData()throws Exception{
		try {
			officesuppliesService.deleteById(id);
			this.getAjaxMessagesJson().setMessage(true, "", "删除成功");
			
		} catch (Exception e) {
			this.handleException(e);
		}
		return RESULT_AJAXJSON;
	}
	
	@SuppressWarnings("unchecked")
	public List getWrapperList() {
		return wrapperList;
	}

	@SuppressWarnings("unchecked")
	public void setWrapperList(List wrapperList) {
		this.wrapperList = wrapperList;
	}

	public IOfficesuppliesService getOfficesuppliesService() {
		return officesuppliesService;
	}

	public void setOfficesuppliesService(
			IOfficesuppliesService officesuppliesService) {
		this.officesuppliesService = officesuppliesService;
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public OfficesuppliesForm getObjctForm() {
		return objctForm;
	}

	public void setObjctForm(OfficesuppliesForm objctForm) {
		this.objctForm = objctForm;
	}

	@SuppressWarnings("unchecked")
	public List getSortList() {
		return sortList;
	}

	@SuppressWarnings("unchecked")
	public void setSortList(List sortList) {
		this.sortList = sortList;
	}

	
}
